package top.superflow.flow.load

import top.superflow.common.LocalFlowConstant
import top.superflow.flow.config.template.TemplateConfig
import top.superflow.json.util.JsonUtils

class TemplateLoader extends Loader[TemplateConfig]{
  def load(json: Any): TemplateConfig = {

    val jsonString : String = JsonUtils.getJson(json)

    val templateConfig = new TemplateConfig()
    templateConfig.setKey(JsonUtils.getField(jsonString, LocalFlowConstant.CONFIG_FIELD_KEY))
    templateConfig.setGroup(JsonUtils.getField(jsonString, LocalFlowConstant.CONFIG_FIELD_GROUP))
    templateConfig.setTemplate(jsonString)

    templateConfig
  }
}
